﻿namespace Gunningine
{
    using System;
    using System.IO;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    
    public class ModelResource : Resource
    {
        /// <summary>
        /// Vertex, contains:
        /// position, normal, 
        /// texcoords
        /// colour
        /// </summary>
        public class Vertex
        {
            public Vector3 p, n;
            public float u, v;
            public float r, g, b, a;
        }

        /// <summary>
        /// Triangle, contains:
        /// indices into vertex list
        /// </summary>
        public class Triangle
        {
            public int[] vertices = new int[3];
        }

        /// <summary>
        /// Animation frame, contains:
        /// list of vertices
        /// </summary>
        public class Frame
        {
            public List<Vertex> vertices = new List<Vertex>();

            public float size;
        }

        /// <summary>
        /// Animation, contains:
        /// list of frames
        /// </summary>
        public class Animation
        {
            public List<Frame> frames = new List<Frame>();
        }

        /// <summary>
        /// Texture.  Most models will not include texture information, but some
        /// formats may.
        /// </summary>
        public class Texture
        {
            public int width, height;
            public int channels;
            public byte[] data;
        }

        /// <summary>
        /// Triangles.
        /// </summary>
        private List<Triangle> triangles = new List<Triangle>();

        public List<Triangle> Triangles
        {
            get { return this.triangles; }
        }

        /// <summary>
        /// Animations.
        /// </summary>
        private Dictionary<string, Animation> animations = new Dictionary<string, Animation>();

        public Dictionary<string, Animation> Animations
        {
            get { return this.animations; }
        }

        /// <summary>
        /// Textures.
        /// </summary>
        List<Texture> textures = new List<Texture>();

        public List<Texture> Textures 
        {
            get { return textures; }
        }

        public int NumVertices { get; set; }
    }
}
